let scrollTimeout
window.addEventListener('scroll', () => {
  clearTimeout(scrollTimeout)
  scrollTimeout = setTimeout(() => {
    const windowHeight = window.innerHeight
    const currentScrollY = window.scrollY
    const targetSectionIndex = Math.round(currentScrollY / windowHeight)
    const targetScrollY = targetSectionIndex * windowHeight

    window.scrollTo({
      top: targetScrollY,
      behavior: 'smooth',
    })
  }, 150)
})
